package cn.edu.scau.cmi.lijiongtao.client;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class comprehensiveClient extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) throws Exception {
		stage.setTitle("综合性实验");
		stage.setHeight(380);
		stage.setWidth(440);
		BorderPane bp = new BorderPane();
		bp.setRight(setCenterPane());
		bp.setLeft(setLeftPane());
		Scene s = new Scene(bp,400,460);
		stage.setScene(s);
		stage.show();
	}
	
	private VBox setLeftPane() {
		VBox vBox = new VBox();
		vBox.setPadding(new Insets(15, 5, 5, 5));
		vBox.setSpacing(20);
		
		Image image = new Image("file:image/photo.jpg");
		ImageView imageView = new ImageView();
		imageView.setFitHeight(230);
		imageView.setFitWidth(210);
		imageView.setImage(image);
		
		Label id = new Label("学号：201627010610");
		Label name = new Label("姓名：李炯涛");
		
		vBox.getChildren().addAll(imageView, id, name);
		return vBox;
	}
	
	private VBox setCenterPane() {
		VBox vBox = new VBox();
		vBox.setPadding(new Insets(15, 5, 5, 5));
		vBox.setSpacing(10);
		Button bt1 = new Button("实验一：接口编程");
		Button bt2 = new Button("实验二：单例模式");
		Button bt3 = new Button("实验二：多例模式");
		Button bt4 = new Button("实验三：简单工厂");
		Button bt5 = new Button("实验三：工厂模式");
		Button bt6 = new Button("实验三：抽象工厂");
		Button bt7 = new Button("实验四：适配器模式");
		Button bt8 = new Button("实验五：安全组合模式");
		Button bt9 = new Button("实验五：一致性组合模式");
		Button bt10 = new Button("实验六：实例分析与数据库设计");
		vBox.getChildren().addAll(bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9, bt10);
		
		bt1.setOnAction(e -> {
			InterProgrammingClient interProgrammingClient = new InterProgrammingClient();
			try {
				interProgrammingClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt2.setOnAction(e -> {
			SingletonClient singletonClient = new SingletonClient();
			try {
				singletonClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt3.setOnAction(e -> {
			MultipletonClient multipletonClient = new MultipletonClient();
			try {
				multipletonClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt4.setOnAction(e -> {
			SimpleFactoryClient simpleFactoryClient = new SimpleFactoryClient();
			try {
				simpleFactoryClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt5.setOnAction(e -> {
			FactoryClient factoryClient = new FactoryClient();
			try {
				factoryClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt6.setOnAction(e -> {
			AbstractFactoryClient abstractFactoryClient = new AbstractFactoryClient();
			try {
				abstractFactoryClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt7.setOnAction(e -> {
			AdapterClient adapterClient = new AdapterClient();
			try {
				adapterClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt8.setOnAction(e -> {
			safeCompositeClient safeCompositeClient = new safeCompositeClient();
			try {
				safeCompositeClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt9.setOnAction(e -> {
			consistentCompositeClient consistentCompositeClient = new consistentCompositeClient();
			try {
				consistentCompositeClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		bt10.setOnAction(e -> {
			TutorSystemClient tutorSystemClient = new TutorSystemClient();
			try {
				tutorSystemClient.start(new Stage());
			} catch (Exception e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		});
		
		return vBox;
	}
}
